package com.tool.builder.BuildTemplate;

import com.tool.bean.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.Locale;
import static com.tool.utils.writeToFileUtils.writeToFile;

public class BuildEnum {

    private static Logger logger = LoggerFactory.getLogger(Locale.Builder.class);
    public static void execute() {

        File folder = new File(Constants.COMMON_PATH_ENUMERATION);
        if (!folder.exists()) {
            folder.mkdirs();
        }

        // 定义目标文件
        File enumFile = new File(folder, "ExceptionEnum.java");

        // 模板路径
        String enumTemplatePath = BuildEnum.class.getClassLoader()
                .getResource("template/ExceptionEnum.txt").getPath();

        // 写入文件逻辑
        try {
            // 写入 AppException 文件
            writeToFile(enumTemplatePath, enumFile, Constants.COMMON_PACKAGE_ENUMERATION);

        }   catch (Exception e) {
            logger.error("生成枚举类失败:{}", e);
        }
    }


}
